import { Component,ViewChild} from '@angular/core';
import { IonicPage, NavController, NavParams,ViewController} from 'ionic-angular';
import {TabsPage} from "../tabs/tabs";
import {ContactPage} from "../contact/contact";
import {MyProvider} from "../../providers/my/my";

@IonicPage()
@Component({
  selector: 'page-settings',
  templateUrl: 'settings.html',
})
export class SettingsPage {

  params = {a:1,b:2,c:3}
  constructor(public navCtrl: NavController, public navParams: NavParams,
              public view:ViewController,public myService:MyProvider) {
    this.params.a = navParams.get('a');
  }

  @ViewChild(ContactPage) contactPage: ContactPage;

  ionViewDidLoad() {
    console.log('ionViewDidLoad SettingsPage');
  }

  //关闭页面
  close(){
    this.view.dismiss({a: 1, b: 2, c: 3})
      .catch(e=>{
          this.navCtrl.push(TabsPage).catch(_=>{
            console.error(_,28);
            this.navCtrl.setRoot(TabsPage)
              .catch(err=>{
                console.info(`PageInfo:${err} not exits!`);
              });
          });
      })
  }

  //子页面控制tab选项
  switchTabs(id:number) {
    this.myService.sendTabBroadcast(id);
  }
}
